package com.dlc.shop.systemtest.data.amount;

import com.dlc.shop.bean.dto.SkuAdminDTO;
import com.dlc.shop.bean.dto.StockPointSkuDTO;
import com.dlc.shop.bean.model.Product;
import com.dlc.shop.bean.model.SkuLang;
import com.dlc.shop.bean.param.ProdLangParam;
import com.dlc.shop.bean.param.ProductParam;
import com.dlc.shop.systemtest.api.order.StockApi;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;

/**
 * @author lanhai
 * 商品测试数据
 */
public class ProductData {
    private static List<StockPointSkuDTO> getStockPointSkuDTOs(){
        Long defaultWareHouseId = StockApi.getStockPoint().getDefaultWarehouseId();

        List<StockPointSkuDTO> stockPointSkuDTOS = new ArrayList<>();
        StockPointSkuDTO stockPointSkuDTO = new StockPointSkuDTO();
        stockPointSkuDTO.setStock(100);
        stockPointSkuDTO.setStockPointId(defaultWareHouseId);
        stockPointSkuDTO.setStockPointType(1);
        stockPointSkuDTO.setType(0);
        stockPointSkuDTOS.add(stockPointSkuDTO);
        return stockPointSkuDTOS;
    }

    public static ProductParam getProductParam(Long shopId, double price, double deliveryAmount, Integer mold,
                                               Long devTemplateId, Long shopCategoryId, Long categoryId){
        ProductParam productParam = new ProductParam();
        productParam.setBrandId(0L);
        productParam.setShopId(shopId);
        productParam.setCategoryId(Objects.isNull(categoryId) ? 107L : categoryId);
        productParam.setShopCategoryId(shopCategoryId);
        productParam.setDeliveryAmount(deliveryAmount);
        productParam.setPrice(price);

        productParam.setMold(mold);
        productParam.setProdName("接口测试商品");
        productParam.setPic("/test.png");
        productParam.setImgs("/test.png");
        productParam.setOriPrice(price);
        productParam.setTotalStocks(100);
        productParam.setProdType(0);
        productParam.setUseLang(0);
        productParam.setDeliveryTemplateId(devTemplateId);
        productParam.setUseLang(0);

        ProdLangParam prodLangParamCn = new ProdLangParam();
        prodLangParamCn.setBrief("123");
        prodLangParamCn.setLang(0);
        prodLangParamCn.setProdName("接口测试商品");
        prodLangParamCn.setContent(" ");
        ProdLangParam productLangParamEn = new ProdLangParam();
        productLangParamEn.setBrief("123");
        productLangParamEn.setLang(1);
        productLangParamEn.setProdName("接口测试商品");
        productLangParamEn.setContent(" ");
        productParam.setProdLangList(Arrays.asList(prodLangParamCn,productLangParamEn));

        // 配送方式
        Product.DeliveryModeVO deliveryModeVO = new Product.DeliveryModeVO();
        deliveryModeVO.setHasShopDelivery(true);
        deliveryModeVO.setHasUserPickUp(true);
        deliveryModeVO.setHasCityDelivery(true);
        productParam.setDeliveryModeVo(deliveryModeVO);

        List<SkuAdminDTO> skuList = new ArrayList<>();
        SkuAdminDTO sku = new SkuAdminDTO();
        sku.setPrice(price);
        sku.setStocks(100);
        sku.setStockWarning(0);
        sku.setStatus(1);
        sku.setWeight(0D);
        sku.setVolume(0D);
        SkuLang skuLangCn = new SkuLang();
        skuLangCn.setSkuName(" ");
        skuLangCn.setLang(0);
        skuLangCn.setSkuId(0L);
        skuLangCn.setProdName("接口测试商品");
        skuLangCn.setProperties("");
        sku.setSkuLangList(List.of(skuLangCn));
        sku.setStockPointList(getStockPointSkuDTOs());
        skuList.add(sku);

        productParam.setSkuList(skuList);
        return productParam;
    }

    public static ProductParam getProductParam(Long shopCategoryId, Long categoryId)
    {
        ProductParam productParam = new ProductParam();
        productParam.setCategoryId(categoryId);
        productParam.setShopCategoryId(shopCategoryId);
        productParam.setTotalStocks(100);
        productParam.setPrice(50.0);
        productParam.setMold(0);
        productParam.setProdName("接口新增实物商品");

        productParam.setPic("/test.png");
        productParam.setImgs("/test.png");
        productParam.setOriPrice(60.0);
        productParam.setTotalStocks(100);
        productParam.setProdType(0);
        productParam.setUseLang(0);
        productParam.setDeliveryTemplateId(0L);

        ProdLangParam prodLangParamCn = new ProdLangParam();
        prodLangParamCn.setBrief("123");
        prodLangParamCn.setLang(0);
        prodLangParamCn.setProdName("接口新增实物商品");
        prodLangParamCn.setContent(" ");
        ProdLangParam productLangParamEn = new ProdLangParam();
        productLangParamEn.setBrief("123");
        productLangParamEn.setLang(1);
        productLangParamEn.setProdName("接口新增实物商品");
        productParam.setProdLangList(Arrays.asList(prodLangParamCn,productLangParamEn));
        productLangParamEn.setContent(" ");

        List<SkuAdminDTO> skuList = new ArrayList<>();
        SkuAdminDTO sku = new SkuAdminDTO();
        sku.setStocks(100);
        sku.setStockWarning(0);
        sku.setStatus(1);
        sku.setPrice(50.0);
        sku.setVolume(0D);
        SkuLang skuLangCn = new SkuLang();
        skuLangCn.setSkuName("");
        skuLangCn.setLang(0);
        skuLangCn.setSkuId(0L);
        sku.setWeight(0D);
        skuLangCn.setProdName("接口新增实物商品");
        skuLangCn.setProperties("");
        sku.setSkuLangList(List.of(skuLangCn));
        sku.setStockPointList(getStockPointSkuDTOs());
        skuList.add(sku);
        // 配送方式
        Product.DeliveryModeVO deliveryModeVO = new Product.DeliveryModeVO();
        deliveryModeVO.setHasShopDelivery(true);
        deliveryModeVO.setHasUserPickUp(true);
        deliveryModeVO.setHasCityDelivery(true);
        productParam.setDeliveryModeVo(deliveryModeVO);
        productParam.setSkuList(skuList);

        return productParam;
    }


    public static ProductParam getProductParam(Long shopCategoryId, Long categoryId,Double deliveryAmount)
    {
        ProductParam productParam = new ProductParam();
        productParam.setCategoryId(categoryId);
        productParam.setShopCategoryId(shopCategoryId);
        productParam.setTotalStocks(100);
        productParam.setPrice(88D);
        productParam.setMold(0);
        productParam.setProdName("接口新增实物商品");

        productParam.setPic("/test.png");
        productParam.setImgs("/test.png");
        productParam.setOriPrice(88D);
        productParam.setTotalStocks(100);
        productParam.setProdType(0);
        productParam.setUseLang(0);

        ProdLangParam prodLangParamCn = new ProdLangParam();
        prodLangParamCn.setBrief("123");
        prodLangParamCn.setLang(0);
        prodLangParamCn.setProdName("接口新增实物商品");
        prodLangParamCn.setContent(" ");
        ProdLangParam productLangParamEn = new ProdLangParam();
        productLangParamEn.setBrief("123");
        productLangParamEn.setLang(1);
        productLangParamEn.setProdName("接口新增实物商品");
        productParam.setProdLangList(Arrays.asList(prodLangParamCn,productLangParamEn));
        productLangParamEn.setContent(" ");

        List<SkuAdminDTO> skuList = new ArrayList<>();
        SkuAdminDTO sku = new SkuAdminDTO();
        sku.setStocks(100);
        sku.setStockWarning(0);
        sku.setStatus(1);
        sku.setPrice(88D);
        sku.setVolume(0D);
        SkuLang skuLangCn = new SkuLang();
        skuLangCn.setSkuName("");
        skuLangCn.setLang(0);
        skuLangCn.setSkuId(0L);
        sku.setWeight(0D);
        skuLangCn.setProdName("接口新增实物商品");
        skuLangCn.setProperties("");
        sku.setSkuLangList(List.of(skuLangCn));
        sku.setStockPointList(getStockPointSkuDTOs());

        skuList.add(sku);
        // 配送方式
        Product.DeliveryModeVO deliveryModeVO = new Product.DeliveryModeVO();
        deliveryModeVO.setHasShopDelivery(true);
        deliveryModeVO.setHasUserPickUp(true);
        deliveryModeVO.setHasCityDelivery(true);
        productParam.setDeliveryModeVo(deliveryModeVO);
        //运费设置
        productParam.setDeliveryTemplateId(-1L);
        productParam.setDeliveryAmount(deliveryAmount);

        productParam.setSkuList(skuList);

        return productParam;
    }
    /**
     * 新增虚拟商品
     * */
    public static ProductParam getUnRealProductParam(Long shopCategoryId, Long categoryId,String writeOffNum,Integer writeOffMultipleCount)
    {
        ProductParam productParam = new ProductParam();
        productParam.setCategoryId(categoryId);
        productParam.setShopCategoryId(shopCategoryId);
        productParam.setPrice(50.0);
        productParam.setTotalStocks(100);
        productParam.setMold(1);
        productParam.setProdName("接口新增虚拟商品");

        productParam.setPic("/test.png");
        productParam.setImgs("/test.png");
        productParam.setOriPrice(60.0);
        productParam.setProdType(0);
        productParam.setDeliveryTemplateId(0L);
        productParam.setUseLang(0);
        productParam.setTotalStocks(100);

        productParam.setWriteOffNum(writeOffNum);
        productParam.setWriteOffMultipleCount(writeOffMultipleCount);
        productParam.setWriteOffTime(1);
        productParam.setIsRefund(1);

        // 配送方式
        Product.DeliveryModeVO deliveryModeVO = new Product.DeliveryModeVO();
        deliveryModeVO.setHasShopDelivery(true);
        deliveryModeVO.setHasUserPickUp(true);
        deliveryModeVO.setHasCityDelivery(true);
        productParam.setDeliveryModeVo(deliveryModeVO);

        ProdLangParam prodLangParamCn = new ProdLangParam();
        prodLangParamCn.setBrief("123");
        prodLangParamCn.setLang(0);
        prodLangParamCn.setProdName("接口新增虚拟商品");
        prodLangParamCn.setContent(" ");
        productParam.setProdLangList(List.of(prodLangParamCn));

        List<SkuAdminDTO> skuList = new ArrayList<>();
        SkuAdminDTO sku = new SkuAdminDTO();
        sku.setPrice(50.0);
        sku.setStocks(100);
        sku.setStockWarning(0);
        sku.setStatus(1);
        sku.setWeight(0D);
        sku.setVolume(0D);
        sku.setStockPointList(getStockPointSkuDTOs());
        SkuLang skuLangCn = new SkuLang();
        skuLangCn.setSkuName("");
        skuLangCn.setLang(0);
        skuLangCn.setSkuId(0L);
        skuLangCn.setProdName("接口新增虚拟商品");
        skuLangCn.setProperties("");
        sku.setSkuLangList(List.of(skuLangCn));
        skuList.add(sku);

        productParam.setSkuList(skuList);

        return productParam;
    }
}
